package com.example.demo.service.run;

import com.example.demo.common.Nginx;
import com.example.demo.pojo.ConfigFile;
import com.example.demo.service.configfile.IConfigFileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

@Component
public class RunService implements ApplicationRunner {

    @Autowired
    IConfigFileService configFileService;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        ConfigFile dbConfigFile = configFileService.fingCofigFileByKey();
        if(dbConfigFile==null){
            ConfigFile configFile=new ConfigFile();
            configFile.setFilePath(Nginx.getNginxMainConf());
            configFile.setKeyMain(1);
            configFileService.save(configFile);
        }
    }
}
